

#pragma once

#include "cocos2d.h"
USING_NS_CC;

#include "type.h"
#include "cardpack.h"

#include <vector>
#include <map>

using namespace std;

struct EquipmentInfo {
	string name;
	EquipmentType type;
	EquipmentRarity rarity;
	int quantity;
};

class ShopScene : public CCScene, public CCTargetedTouchDelegate, public CCKeypadDelegate {
public:
	ShopScene();
	virtual ~ShopScene();

    CREATE_FUNC(ShopScene);

private:
	virtual bool init();

	void slidePacksView(float distance);
	pair<string, int> createEquipment(EquipmentType type, EquipmentRarity rarity, int minNum, int maxNum);

	void onRecharge(CCObject* sender);
	void onBuyPack(CCObject* sender);
	void onClose(CCObject* sender);
	void onCloseViewOfEquipmentBought(CCObject* sender);

	void showViewOfEquipmentBought(const vector<EquipmentInfo>& items);

	virtual bool ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent);
	virtual void ccTouchMoved(CCTouch *pTouch, CCEvent *pEvent);
	virtual void ccTouchEnded(CCTouch *pTouch, CCEvent *pEvent);
	virtual void ccTouchCancelled(CCTouch *pTouch, CCEvent *pEvent);
	
	virtual void keyBackClicked();
	virtual void keyMenuClicked();

private:
	CCLayer* _layer;
	CCLayer* _layerPacks;

	int _selectedTabIndex;
	int _touchedTabButtonIndex;
	int _touchedEquipmentIndex;

	vector<CCSprite*>* _arrSprites[(int)CardPackType::count];

	CCLabelTTF* _labelMoney;

	char buf[50];

	virtual void onEnter();

	virtual void onExit();
};
